﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SangoBang
{
    class KillAction : Action
    {
        public KillAction(Player sender, Player receiver)
            : base(sender, receiver)
        { 
        
        }
        
        public override string Do()
        {
            StringBuilder rtnMsg = new StringBuilder(512);
            //kill方 减去一个张牌
            --this.Sender.CardNumber;

            rtnMsg.Append("<message type=\"playerAction\"><action type=\"kill\" player=\"");
            rtnMsg.Append(this.Sender.mName); 
            rtnMsg.Append("\" target=\"");  
            rtnMsg.Append(this.Receiver.mName);  
            rtnMsg.Append("\"></action></message>");


            foreach (Player player in this.Receiver.Game.mPlayerList)
            {
                lock (player.MessageQueue)
                {
                    player.MessageQueue.Enqueue(rtnMsg.ToString());
                }
                player.MessageEvent.Set();

            }

            return string.Empty;
        }
    }
}
